<template>
  <div style="background-color: white">
    <my-header></my-header>
    <el-container style="height: 800px; border: 1px solid #eee;">

      <el-aside width="200px" style="margin-top: 1%" >
        <div style="width: 190px;background-color: white;padding: 5px;margin: auto">
          <img v-model="user.userPic" v-bind:src="user.userPic" width="150px" height="150px" style="border-radius: 300px;margin-left: 8%">
          <br>
          <br>
          <p style="margin:0 auto;text-align: center" v-model="user.userName">{{user.userName}}</p>
        </div>
        <el-button  class="el-icon-user-solid" round @click="loginOut">退出登录</el-button>
        <br>
        <br>
        <el-menu :default-openeds="['1','2','3']">
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-message"></i>用户中心</template>
            <el-menu-item-group>

              <router-link class="alink" to="/spaceinfo"><el-menu-item index="1-1">个人信息</el-menu-item></router-link>
              <router-link class="alink" to="/changepic"><el-menu-item index="1-2">修改密码</el-menu-item></router-link>
              <router-link class="alink" to="/changeinfo"><el-menu-item index="1-3">编辑信息</el-menu-item></router-link>
            </el-menu-item-group>

          </el-submenu>
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-menu"></i>创作中心</template>
            <el-menu-item-group>
<<<<<<< HEAD
              <router-link class="alink" to="/space/wirterboke"><el-menu-item index="2-2">发布文章</el-menu-item></router-link>
=======
<!--              <router-link class="alink" to="/space/bokelist"><el-menu-item index="2-1">发布历史</el-menu-item></router-link>-->
              <router-link class="alink" to="/Reg"><el-menu-item index="2-2">发布文章</el-menu-item></router-link>
>>>>>>> daa5e896c9746cc56abce05c01bf21b66d6b58bc
            </el-menu-item-group>

          </el-submenu>


        </el-menu>
      </el-aside>


      <el-container style="background-color: white">
        <el-main>
          <router-view/>
        </el-main>
      </el-container>



    </el-container>

  </div>
</template>

<script>
export default {
  name: "Space",
  // beforeRouteEnter: (to, from, next) => {
  //   console.log("准备进入个人信息页");
  //   let islogin = sessionStorage.getItem("isLogin")
  //   if(!islogin){
  //     next({path:'/login'});
  //   }
  //   next();
  // },
  data() {

    return {
      user:{
        userPic :"static/img/qq.jpg",
        userName: 'admin'
      }
    }
  },
  mounted() {
    this.getUser()
  },
  methods:{
    getUser(res){
      //从session中取出"user"
      this.$axios.post("/api/user/show").then(res=> {
        this.user = res.data.data

      })

      },
    loginOut(){
      this.$axios.get("/api/user/loginOut").then(res=>{
          if(res.data.code==1){
            this.$router.push("/")
          }
      })
    }
    }
}
</script>

<style scoped>
.el-header {
  background-color: #B3C0D1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
.alink{

  text-decoration: none;
}
</style>



